﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using YArchitech.Controls;
using YArchitech.LIB;

namespace HYRElectric.Calculate
{
	public partial class DlgAddRef : System.Windows.Forms.Form
	{
		public DlgAddRef(DlgLYXS main)
		{
			this.mainForm = main;
			this.InitializeComponent();
		}

		private void button2_Click(object sender, EventArgs e)
		{
			base.Close();
		}

		private void button1_Click(object sender, EventArgs e)
		{
			int c = 0;
			int w = 0;
			int g = 0;
			if (int.TryParse(this.tbxCei.Text, out c) && int.TryParse(this.tbxWall.Text, out w) && int.TryParse(this.tbxGround.Text, out g))
			{
				FactorGroup factorGroup = new FactorGroup(c, w, g);
				if (!this.mainForm.dataGridView.Columns.Contains(factorGroup.ToString()))
				{
					this.mainForm.dataGridView.Columns.Add(factorGroup.ToString(), factorGroup.ToString());
					this.mainForm.button4.Enabled = true;
				}
				else
				{
					MessageBox.Show("数据已存在！");
				}
				base.Close();
				return;
			}
			MessageBox.Show("请正确填写数据");
		}

		private void DlgAddRef_Load(object sender, EventArgs e)
		{
			//base.Icon = Resource.YArchitechIcon;
		}

		private DlgLYXS mainForm;
	}
}
